package com.ruoyi.web.controller.broadcast;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.broadcast.domain.Gbhz;
import com.ruoyi.broadcast.service.IGbhzService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 广播话站Controller
 * 
 * @author hcc
 * @date 2024-12-01
 */
@RestController
@RequestMapping("/control/gbhz")
public class GbhzController extends BaseController
{
    @Autowired
    private IGbhzService gbhzService;

    /**
     * 查询广播话站列表
     */
    @PreAuthorize("@ss.hasPermi('control:gbhz:list')")
    @GetMapping("/list")
    public TableDataInfo list(Gbhz gbhz)
    {
        startPage();
        List<Gbhz> list = gbhzService.selectGbhzList(gbhz);
        return getDataTable(list);
    }

    /**
     * 导出广播话站列表
     */
    @PreAuthorize("@ss.hasPermi('control:gbhz:export')")
    @Log(title = "广播话站", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Gbhz gbhz)
    {
        List<Gbhz> list = gbhzService.selectGbhzList(gbhz);
        ExcelUtil<Gbhz> util = new ExcelUtil<Gbhz>(Gbhz.class);
        util.exportExcel(response, list, "广播话站数据");
    }

    /**
     * 获取广播话站详细信息
     */
    @PreAuthorize("@ss.hasPermi('control:gbhz:query')")
    @GetMapping(value = "/{broadcastId}")
    public AjaxResult getInfo(@PathVariable("broadcastId") String broadcastId)
    {
        return success(gbhzService.selectGbhzByBroadcastId(broadcastId));
    }

    /**
     * 新增广播话站
     */
    @PreAuthorize("@ss.hasPermi('control:gbhz:add')")
    @Log(title = "广播话站", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Gbhz gbhz)
    {
        return toAjax(gbhzService.insertGbhz(gbhz));
    }

    /**
     * 修改广播话站
     */
    @PreAuthorize("@ss.hasPermi('control:gbhz:edit')")
    @Log(title = "广播话站", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Gbhz gbhz)
    {
        return toAjax(gbhzService.updateGbhz(gbhz));
    }

    /**
     * 删除广播话站
     */
    @PreAuthorize("@ss.hasPermi('control:gbhz:remove')")
    @Log(title = "广播话站", businessType = BusinessType.DELETE)
	@DeleteMapping("/{broadcastIds}")
    public AjaxResult remove(@PathVariable String[] broadcastIds)
    {
        return toAjax(gbhzService.deleteGbhzByBroadcastIds(broadcastIds));
    }
}
